﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.EquipmentManagement;

namespace Digitalmes.Model.EquipmentManagement
{
    /// <summary>
    /// 设备变量
    /// </summary>
	[Table("EquipmentTag")]

    [Display(Name = "_Model.EquipmentTag")]
    public class EquipmentTag : BasePoco,IPersistPoco,ITenant
    {


        [Key]
        [Display(Name = "_Model._EquipmentStateRecord._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }

        [Display(Name = "_Model._EquipmentTag._TagName")]
        [Comment("变量名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string TagName { get; set; }
        [Display(Name = "_Model._EquipmentTag._Address")]
        [Comment("地址")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Address { get; set; }
        [Display(Name = "_Model._EquipmentTag._Equipment")]
        [Comment("关联设备")]
        public Equipment Equipment { get; set; }
        [Display(Name = "_Model._EquipmentTag._Equipment")]
        [Comment("关联设备")]
        public long? EquipmentId { get; set; }
        [Display(Name = "_Model._EquipmentTag._Description")]
        [Comment("描述")]
        public string Description { get; set; }
        [Display(Name = "_Model._EquipmentTag._TagType")]
        [Comment("变量类型")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public TagDefineEnum TagType { get; set; }
        [Display(Name = "_Model._EquipmentTag._DataType")]
        [Comment("数据类型")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public TagDataTypeEnum DataType { get; set; }
        [Display(Name = "_Model._EquipmentTag._ScanRate")]
        [Comment("扫描速率")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? ScanRate { get; set; } = 100;
        [Display(Name = "_Model._EquipmentTag._GroupType")]
        [Comment("信号组")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public TagGroupEnum GroupType { get; set; }
        [Display(Name = "_Model._EquipmentTag._AccessMode")]
        [Comment("访问模式")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public TagAccessModeEnum AccessMode { get; set; }
        [Display(Name = "_Model._EquipmentTag._Aux_1")]
        [Comment("备用1")]
        public string Aux_1 { get; set; }
        [Display(Name = "_Model._EquipmentTag._Aux_2")]
        [Comment("备用2")]
        public string Aux_2 { get; set; }
        [Display(Name = "_Model._EquipmentTag._Active")]
        [Comment("激活")]

        public bool Active { get; set; } = false;

        [Display(Name = "_Model._EquipmentTag._DriverType")]
        [Comment("驱动类型")]
        public DriverTypeEnum? DriverType { get; set; }
        [Display(Name = "_Model._EquipmentTag._UpLimit")]
        [Comment("上限")]
        [Precision(18,3)]
        public decimal? UpLimit { get; set; }
        [Display(Name = "_Model._EquipmentTag._LowerLimit")]
        [Comment("下限")]
        [Precision(18,3)]
        public decimal? LowerLimit { get; set; }
        [Display(Name = "_Model._EquipmentTag._ActiveLimit")]
        [Comment("激活上下限")]
        public bool ActiveLimit { get; set; } = false;

        [Display(Name = "_Model._EquipmentTag._EquipCode")]
        [Comment("设备编码")]
        public string EquipCode { get; set; }
        [Display(Name = "_Model._EquipmentAlarmItem._EquipTag")]
        [InverseProperty("EquipTag")]
        public List<EquipmentAlarmItem> EquipmentAlarmItem_EquipTag { get; set; }
        [Display(Name = "_Model._EquipmentTag._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
